const {Menu, User, UserAndRole, Role, UserInfo} = require('./model/index')
const doCrypto = require('../utils/cryp')

;(async function () {
  await Menu.destroy({
    truncate: true
  })
  Menu.bulkCreate([
    {name: '用户管理', href: '/userManage'},
    {name: '角色管理', href: '/roleManage'},
    {name: '授权管理', href: '/authManage'},
    {name: '个人信息', href: '/userInfo'},
    {name: '地区管理', href: '/areaManage'},
    {name: '学区管理', href: '/schoolManage'},
    {name: '房屋管理', href: '/houseManage'},
    {name: '房屋市场', href: '/houseShops'},
    {name: '我的房屋', href: '/houseMyManage'},
    {name: '请求管理', href: '/askManage'},
    {name: '我发起的请求', href: '/askMyManage'},
    {name: '我收到的请求', href: '/askYoursManage'},
    {name: '租约管理', href: '/leaseManage'},
    {name: '我收到的租约', href: '/leaseMyManage'},
    {name: '我发起的租约', href: '/leaseYoursManage'},
    {name: '论坛', href: '/commentManage'}
  ])
})()

;(async function () {
  await User.bulkCreate([
    {userName: 'admin', password: doCrypto('123456'), nickName: '大明锅'}
  ])
  await Role.bulkCreate([
    {name: '管理员', auth: 'all', isSchool: true, description: '管理员最高权限'},
    {name: '普通用户', auth: '4', isSchool: false, description: '普通用户'}
  ])
  await UserAndRole.bulkCreate([
    {uid: 1, rid: 1}
  ])
  await UserInfo.bulkCreate([
    {uid: 1}
  ])
})()

